﻿using System;
using System.Text;

namespace WebTest.Infrastructure.NLog
{
    public class LogMessage
    {
        public string Host { get; private set; }
        public string Createor { get; private set; }
        public DateTime CreateDateTime { get; private set; }
        public string Body { get; private set; }
        public string StackTrace { get; private set; }
        public LogMessage(string body, string host, string creator, string stackTrace)
        {
            Body = body ?? throw new ArgumentNullException(nameof(body));
            Host = host;
            Createor = creator;
            CreateDateTime = DateTime.UtcNow;
            StackTrace = stackTrace;
        }
        public string Format()
        {
            StringBuilder @string = new StringBuilder();
            @string.AppendLine($"{CreateDateTime}\t:{Createor}\t{Host}");
            @string.AppendLine($"Message\t:{Body}");
            @string.AppendLine($"StackTrace\t:{StackTrace}").AppendLine();

            return @string.ToString();
        }
    }
}
